#ifndef _NETWORK_INCLUDE_VSOMEIPSERVER_H
#define _NETWORK_INCLUDE_VSOMEIPSERVER_H

#include <vsomeip/vsomeip.hpp>
#include <chrono>
#include <condition_variable>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <thread>
#include <mutex>

namespace network
{

class VsomeipServer 
{
public:
    VsomeipServer(bool _use_tcp);

    bool init();
    void start();
    void stop();
    void offer();
    void stop_offer();

private:
    void onState(vsomeip::state_type_e _state);
    void onGet(const std::shared_ptr<vsomeip::message> &_message);
    void onSet(const std::shared_ptr<vsomeip::message> &_message);
    void onMessage(const std::shared_ptr<vsomeip::message>& message);
    void onUnknownMethod(const std::shared_ptr<vsomeip::message>& message);
    bool onRegisterSubscription(vsomeip::client_t, vsomeip::uid_t, vsomeip::gid_t, bool);

    void run();
    void notify();

    void printMessage(const std::shared_ptr<vsomeip::message> &_message);

    std::shared_ptr<vsomeip::application> itsApp;
    bool use_tcp_;
    uint32_t cycle_;

    static constexpr auto SAMPLE_SERVICE_ID = 0x1234;
    static constexpr auto SAMPLE_INSTANCE_ID = 0xffff;
    static constexpr auto SAMPLE_METHOD_ID = 0x0421;
    static constexpr auto SAMPLE_EVENT_ID = 0x8778;
    static constexpr auto E2E_EVENT_ID = 0x0777;
    static constexpr auto E2E_EVENT_ID_2 = 0x0778;
    static constexpr auto SAMPLE_GET_METHOD_ID = 0x0001;
    static constexpr auto SAMPLE_SET_METHOD_ID = 0x0002;
    static constexpr auto SAMPLE_EVENTGROUP_ID = 0x4465;
    static constexpr auto E2E_EVENTGROUP_ID = 0x4455;
    static constexpr auto OTHER_SAMPLE_SERVICE_ID = 0x0248;
    static constexpr auto OTHER_SAMPLE_INSTANCE_ID = 0x5422;
    static constexpr auto E2E_SAMPLE_INSTANCE_ID = 0x0011;
    static constexpr auto OTHER_SAMPLE_METHOD_ID  =  0x1421;
};


} 

#endif